function net = get_net(net)
% Input:
%   net.file
%   net.name
% CodeAuthor:   Mordecai Lee (mordekai@qq.com)
% CreatedDate:  2017-05-17, Wed, 12:48:58

% net.output = 'r';
if ~str(net.file).isendwith('.prototxt')
    net.file = [net.file '.prototxt'];
end

net.file = fullfile(VDSR.path, net.file);

%%
net.content = strtrim(fileread(net.file));
% mycaffe.net.getLayer(net.content, 'data');

%%
net.content = mycaffe.net.setName(net.content, net.name);

%%
net.content = regexprep(net.content, 'kernel_size\s*:\s*\d+', ['kernel_size: ' num2str(net.kernel_size)], 'ignorecase');
net.content = regexprep(net.content, 'pad\s*:\s*\d+', ['pad: ' num2str(floor(net.kernel_size/2))], 'ignorecase');

%%
net = mycaffe.net.parseWeightInitParam(net);
switch lower(net.weight_init_type)
    case 'gaussian'
        weight_param = sprintf('type: "%s"\n\t\tstd: %s', net.weight_init_type, num2str(net.std));
    otherwise
        weight_param = sprintf('type: "%s"', net.weight_init_type);
end
weight_filler = sprintf('weight_filler {\n\t%s\n\t}', weight_param);
net.content = regexprep(net.content, 'weight_filler\s*{[^\}]*}', weight_filler, 'ignorecase');

%%
if strcmpi(net.output, 'y') && ~str(net.name).isendwith('noskip')
    return
end

[i1, j1] = mycaffe.net.getLayer(net.content, 'sum');
[i2, j2] = mycaffe.net.getLayer(net.content, 'loss');
bottom_of_sum_layer = regexp(net.content(i1 : j1), 'bottom\s*:\s*"\w*conv\w+"', 'match');
loss_layer = regexprep(net.content(i2 : j2), 'bottom\s*:\s*"sum"', bottom_of_sum_layer{1});
net.content([i1:j1, i2:j2]) = [];
net.content = [strtrim(net.content) sprintf('\n') loss_layer];

return
